package com.zfj.controller;


import com.zfj.entity.subject.OneSubject;
import com.zfj.service.EduSubjectService;
import com.zfj.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author zfj
 * @since 2022-10-06
 */
@RestController
@RequestMapping("/eduService/edu-subject")
@CrossOrigin
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;

    //添加课程
    //获取上传文件，将文件读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        //上传到excel
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }

    //课程分类列表(树形)
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<OneSubject> list;
        list = subjectService.getOneTwoSubject();
        return R.ok().data("list",list);
    }
}

